package com.huobao.yunying.utils;

import android.content.Context;
import android.content.Intent;
import android.text.TextUtils;

import com.huobao.yunying.activitys.Act_Jinritehui;
import com.huobao.yunying.activitys.Act_KeTang;
import com.huobao.yunying.activitys.Act_Ketang_detail;
import com.huobao.yunying.activitys.Act_RegYouli;
import com.huobao.yunying.activitys.Act_Temai_Detail;
import com.huobao.yunying.activitys.muyingquan.Act_Tiezi_Detail;
import com.huobao.yunying.activitys_store.Act_Store;
import com.huobao.yunying.entity.FristPageList;

/**
 * Created by Administrator on 2016/9/9.
 */
public class LinkTypeUtils {
	private String ad_id, ad_link, ad_logo, ad_name, link_type, link_id, spec_id;
	private Context context;

	public LinkTypeUtils(Context context, String ad_id, String ad_link, String ad_logo, String ad_name, String link_type, String link_id, String spec_id) {
		this.ad_id = ad_id;
		this.ad_link = ad_link;
		this.ad_logo = ad_logo;
		this.ad_name = ad_name;
		this.link_type = link_type;
		this.link_id = link_id;
		this.spec_id = spec_id;
		this.context = context;
	}

	public void skip(boolean newTask) {
		String type = link_type;
		if (TextUtils.isEmpty(type)) return;
		int itype = -1;
		try {
			itype = Integer.parseInt(type);
		} catch (Exception e) {
			return;
		}
		switch (itype) {
			case 1://课堂
				Intent intent = new Intent(context, Act_Ketang_detail.class);
				if (newTask)
					intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
				intent.putExtra("id", link_id);
				context.startActivity(intent);
				break;
			case 2://商品详情
				if (newTask)
					SkipUtils.seeDetailnEWtASK(context, link_id + "", ad_logo);
				else
					SkipUtils.seeDetail(context, link_id + "", ad_logo);
				break;
			case 3://店铺
				Intent intent1 = new Intent(context, Act_Store.class);
				if (newTask)
					intent1.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
				intent1.putExtra("id", link_id);
				context.startActivity(intent1);
				break;
			case 4://跳转到浏览器
				OpenBrowUtils.startBrower(context, ad_link);
				break;
			case 5://贴子详情页
				intent = new Intent(context, Act_Tiezi_Detail.class);
				if (newTask)
					intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
				intent.putExtra("id", link_id);
				context.startActivity(intent);
				break;
			case 6://跳转到专题
				intent = new Intent(context, Act_Temai_Detail.class);
				if (newTask)
					intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
				FristPageList list = new FristPageList();
				list.setAd_name(ad_name);
				list.setAd_recomm(spec_id);
				list.setAd_id(link_id);
				intent.putExtra("data", list);
				context.startActivity(intent);
				break;
			case 7://今日特惠
				intent = new Intent(context, Act_Jinritehui.class);
				if (newTask)
					intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
				context.startActivity(intent);
				break;
			case 8://注册送礼
				intent = new Intent(context, Act_RegYouli.class);
				if (newTask)
					intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
				context.startActivity(intent);
				break;
			case 9://课堂首页
				intent = new Intent(context, Act_KeTang.class);
				if (newTask)
					intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
				context.startActivity(intent);
				break;
		}
	}
}
